import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/hidden_danger_investigation_ledger_entity.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';

///年度隐患排查计划
class AnnualHazardInvestigationPlanController extends GetxController {
  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();
  String searchX = '';

  /// 筛选右侧栏控制Key
  final riskRightScaffoldKey = GlobalKey<ScaffoldState>();

  /// 排查计划点击详情
  void onClickButtonPressed(HiddenDangerInvestigationLedgerRecords item) {
    Get.toNamed(AppRoutes.annualHazardInvestigationPlanDetailPage, arguments: item);
  }

  Future<List<HiddenDangerInvestigationLedgerRecords>> getPatrolScheme(int index, int size, {String? search}) async {
    final res = await HttpUtil().generateGetRequest<List<HiddenDangerInvestigationLedgerRecords>>(
      Interface.getPatrolScheme,
      queryParameters: {
        'pageNum': index,
        'pageSize': size,
        'planName': searchX,
        'patrolOrTroubleshooting': 2, //巡检计划或排查计划 1:巡检计划 2:排查计划
        'departmentId': '', //部门id
        'isApprovalPage': '1', //是否查询审批数据 1是 0否	(我的)
      },
    ).execute();
    List<HiddenDangerInvestigationLedgerRecords>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
      }
    });
    return list!;
  }
}
